﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using InHD.model;
using System.Windows.Input;
using InHD.dataaccess;
using System.Windows.Controls;
using System.Collections.ObjectModel;
using InHD.commands;
using System.Windows;
using InHD.Properties;

namespace InHD.viewmodels
{
    class AccountViewModel: WorkspaceViewModel
    {

        #region Constructor
        public AccountViewModel()
        {
            this._accountRepository = new AccountRepository();
            LoadAccountList();
            this.PageContent = new AccountsListViewModel(this._accountRowCollection);
        }
        #endregion

        #region Value Property
        readonly AccountRepository _accountRepository;
        private WorkspaceViewModel _pageContent;
        private List<Account> _accountRowCollection = new List<Account>();
        private int _rowIndex = -1;
        #endregion

        #region Presentation Property

        public WorkspaceViewModel PageContent
        {
            get
            {
                return _pageContent;
            }
            set
            {
                _pageContent = value;
            }
        }

        #endregion

        #region Normal Method
        private void LoadAccountList()
        {
            this._accountRepository.LoadAllAccounts();
            this._accountRowCollection = this._accountRepository.GetAccounts();
        }
        #endregion

        public override string DisplayName
        {
            get
            {
                try
                {
                    return Resources.Title_Acc;
                }
                catch (Exception ex)
                {
                    return string.Empty;
                }
            }
            
        }
    }
}
